package com.yk.points.service.impl;

import java.util.List;

import com.yk.common.constant.UserConstants;
import com.yk.common.utils.DateUtils;
import com.yk.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yk.points.mapper.PointsAmountMapper;
import com.yk.points.domain.PointsAmount;
import com.yk.points.service.IPointsAmountService;
import com.yk.common.core.text.Convert;

/**
 * 金额兑换积分Service业务层处理
 * 
 * @author xufei
 * @date 2025-04-28
 */
@Service
public class PointsAmountServiceImpl implements IPointsAmountService 
{
    @Autowired
    private PointsAmountMapper pointsAmountMapper;

    /**
     * 查询金额兑换积分
     * 
     * @param id 金额兑换积分主键
     * @return 金额兑换积分
     */
    @Override
    public PointsAmount selectPointsAmountById(Long id)
    {
        return pointsAmountMapper.selectPointsAmountById(id);
    }

    /**
     * 查询金额兑换积分列表
     * 
     * @param pointsAmount 金额兑换积分
     * @return 金额兑换积分
     */
    @Override
    public List<PointsAmount> selectPointsAmountList(PointsAmount pointsAmount)
    {
        return pointsAmountMapper.selectPointsAmountList(pointsAmount);
    }

    /**
     * 新增金额兑换积分
     * 
     * @param pointsAmount 金额兑换积分
     * @return 结果
     */
    @Override
    public int insertPointsAmount(PointsAmount pointsAmount)
    {
        pointsAmount.setCreateTime(DateUtils.getNowDate());
        pointsAmount.setCreateBy(ShiroUtils.getLoginName());
        pointsAmount.setDelFlag("0");
        return pointsAmountMapper.insertPointsAmount(pointsAmount);
    }

    /**
     * 修改金额兑换积分
     * 
     * @param pointsAmount 金额兑换积分
     * @return 结果
     */
    @Override
    public int updatePointsAmount(PointsAmount pointsAmount)
    {
        pointsAmount.setUpdateTime(DateUtils.getNowDate());
        pointsAmount.setUpdateBy(ShiroUtils.getLoginName());
        return pointsAmountMapper.updatePointsAmount(pointsAmount);
    }

    /**
     * 批量删除金额兑换积分
     * 
     * @param ids 需要删除的金额兑换积分主键
     * @return 结果
     */
    @Override
    public int deletePointsAmountByIds(String ids)
    {
        return pointsAmountMapper.deletePointsAmountByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除金额兑换积分信息
     * 
     * @param id 金额兑换积分主键
     * @return 结果
     */
    @Override
    public int deletePointsAmountById(Long id)
    {
        return pointsAmountMapper.deletePointsAmountById(id);
    }
}
